import { S } from '../../s';
import { IPSAppDEFLogic } from './ipsapp-deflogic';
import { IPSAppDEField } from './ipsapp-defield';
import { IPSAppDataEntity } from './ipsapp-data-entity';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppDEFieldImpl2
  extends PSModelObjectImpl
  implements IPSAppDEField
{
  get codeName(): string {
    return this.M.codeName;
  }

  protected computepsappdeflogic: IPSAppDEFLogic;
  getComputePSAppDEFLogic(): IPSAppDEFLogic | null {
    if (this.computepsappdeflogic != null) return this.computepsappdeflogic;
    const value = this.M.getComputePSAppDEFLogic;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getParentPSModelObject(
      S._f,
    ) as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.computepsappdeflogic = ipsappdataentity.findPSAppDELogic(
        value,
      ) as IPSAppDEFLogic;
    }
    return this.computepsappdeflogic;
  }

  get defaultValue(): string {
    return this.M.defaultValue;
  }

  protected defaultvaluepsappdeflogic: IPSAppDEFLogic;
  getDefaultValuePSAppDEFLogic(): IPSAppDEFLogic | null {
    if (this.defaultvaluepsappdeflogic != null)
      return this.defaultvaluepsappdeflogic;
    const value = this.M.getDefaultValuePSAppDEFLogic;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getParentPSModelObject(
      S._f,
    ) as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.defaultvaluepsappdeflogic = ipsappdataentity.findPSAppDELogic(
        value,
      ) as IPSAppDEFLogic;
    }
    return this.defaultvaluepsappdeflogic;
  }

  get defaultValueType():
    | 'SESSION'
    | 'APPLICATION'
    | 'UNIQUEID'
    | 'CONTEXT'
    | 'PARAM'
    | 'OPERATOR'
    | 'OPERATORNAME'
    | 'CURTIME'
    | 'APPDATA'
    | 'EXPRESSION'
    | 'USER'
    | 'USER2'
    | 'USER3'
    | 'USER4' {
    return this.M.defaultValueType;
  }

  protected lnpslanguageres: IPSLanguageRes;
  getLNPSLanguageRes(): IPSLanguageRes | null {
    return (
      this.lnpslanguageres ||
      (this.lnpslanguageres = this.fillObjectModel(
        S._276,
        this.M.getLNPSLanguageRes,
        S._2a0,
      ) as IPSLanguageRes)
    );
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get maxValueString(): string {
    return this.M.maxValueString;
  }

  get minStringLength(): number {
    return this.M.minStringLength != null ? this.M.minStringLength : 0;
  }

  get minValueString(): string {
    return this.M.minValueString;
  }

  protected onchangepsappdeflogic: IPSAppDEFLogic;
  getOnChangePSAppDEFLogic(): IPSAppDEFLogic | null {
    if (this.onchangepsappdeflogic != null) return this.onchangepsappdeflogic;
    const value = this.M.getOnChangePSAppDEFLogic;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getParentPSModelObject(
      S._f,
    ) as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.onchangepsappdeflogic = ipsappdataentity.findPSAppDELogic(
        value,
      ) as IPSAppDEFLogic;
    }
    return this.onchangepsappdeflogic;
  }

  get precision(): number {
    return this.M.precision != null ? this.M.precision : 0;
  }

  protected qsphpslanguageres: IPSLanguageRes;
  getQSPHPSLanguageRes(): IPSLanguageRes | null {
    return (
      this.qsphpslanguageres ||
      (this.qsphpslanguageres = this.fillObjectModel(
        S._276,
        this.M.getQSPHPSLanguageRes,
        S._3d6,
      ) as IPSLanguageRes)
    );
  }

  get quickSearchPlaceHolder(): string {
    return this.M.quickSearchPlaceHolder;
  }

  get stdDataType():
    | 0
    | 1
    | 2
    | 3
    | 4
    | 5
    | 6
    | 7
    | 8
    | 9
    | 10
    | 11
    | 12
    | 13
    | 14
    | 15
    | 16
    | 17
    | 18
    | 19
    | 20
    | 21
    | 22
    | 23
    | 24
    | 25
    | 26
    | 27
    | 28
    | 29 {
    return this.M.stdDataType;
  }

  get stringLength(): number {
    return this.M.stringLength != null ? this.M.stringLength : 0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get valueFormat(): string {
    return this.M.valueFormat;
  }

  get dataTypeField(): boolean {
    return this.M.dataTypeField != null ? this.M.dataTypeField : false;
  }

  get enableFrontOnly(): boolean {
    return this.M.enableFrontOnly != null ? this.M.enableFrontOnly : false;
  }

  get enableQuickSearch(): boolean {
    return this.M.enableQuickSearch != null ? this.M.enableQuickSearch : false;
  }

  get keyField(): boolean {
    return this.M.keyField != null ? this.M.keyField : false;
  }

  get majorField(): boolean {
    return this.M.majorField != null ? this.M.majorField : false;
  }
  get cls(): string {
    return 'PSAppDEFieldImpl2';
  }
  instanceof(cls: string): boolean {
    if (cls == S._1) return true;
    return super.instanceof(cls);
  }
}
